//
//  DragButtonViewController.m
//  Flower
//
//  Created by 花花 on 2016/12/2.
//  Copyright © 2016年 花花. All rights reserved.
//

#import "DragButtonViewController.h"
#import "UIButton+HHCategory.h"
@interface DragButtonViewController ()
@end

@implementation DragButtonViewController

- (void)viewDidLoad {
    [super viewDidLoad];
  
    self.view.backgroundColor =[UIColor whiteColor];
   
    [self setupbtn];
    
  }


-(void)setupbtn{
    UIButton *btn1 =[self frame:CGRectMake(10, 150, 60, 60) bgImage:@"Smile" tag:333];
    [btn1 setDragEnable:YES];
    [btn1  setAdsorbEnable:YES];
    
    UIButton *btn2=[self frame:CGRectMake(self.view.centerX, 300, 60, 60) bgImage:@"Smile-1" tag:666];
    
    [btn2 setDragEnable:YES];
    [btn2 setAdsorbEnable:NO];


}

-(UIButton *)frame:(CGRect)farme bgImage:(NSString *)bgImage tag:(NSInteger)tag{
    UIButton *btn = [[UIButton alloc]initWithFrame:farme];
    [btn setImage:[UIImage imageNamed:bgImage] forState:UIControlStateNormal];

    btn.tag = tag;
    [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
    return btn;
}
-(void)btnClick:(UIButton *)btn{
    NSLog(@"btn--%@--",@(btn.tag));
   }

@end
